/*
 * @lc app=leetcode id=168 lang=cpp
 *
 * [168] Excel Sheet Column Title
 */
class Solution {
public:
    string convertToTitle(int n) {
        string s;
        if (n < 1) {
            return s;
        }

        while (n > 0) {
            s.push_back('A' + (n-1)%26);
            n = (n-1)/26;
        }
        reverse(s.begin(), s.end());
        return s;
    }
};

